package com.aliang.book_java1.po.反射;

import java.lang.reflect.Method;

public class Example {
    public static void main(String[] args) throws Exception {
        // 获取Example类的Class对象
        Class<?> clazz = Example.class;

        // 获取printMessage方法的Method对象
        Method method = clazz.getMethod("printMessage", String.class);

        // 调用printMessage方法
        method.invoke(null, "Hello, World!");
    }

    public static void printMessage(String message) {
        System.out.println(message);
    }
}
